#ifndef _MOTECOLLECTION_H
#define _MOTECOLLECTION_H

#include <vector>
#include "Mote.h"
#include "MoteBridge.h"
#include <iostream>
#include "globals.h"

#undef DEBUG
#ifdef DEBUG_MOTECOLLECTION
#include <iostream>
#define DEBUG(message) std::cout << message << std::endl;
#else
#define DEBUG(message) 
#endif

#define POLLDELAY 20000

using namespace std;

/*!
 * \brief MoteCollection contains a list of all motes currently connected to MoteBridge
 * \author Khalid Alhokail, Vineet Gupta, Oren Melzer, David Schneider
 *
 */
class MoteCollection
{
	static const int DEFAULT_MOTE_COUNT = 1;
	static const int MAX_MOTE_COUNT = 255;
		
public:
	MoteCollection();
	~MoteCollection();
	int Count() const;
	int MotePosition(int moteId) const;
	bool MoteExists(int moteId) const;
	int LightLevel();
	int DarkLevel();
	void ResetLevels();
	const vector <Mote*> Motes() const;
	bool setLEDs(int moteId, short LEDs);
	
private:
	int lightLevel;
	int darkLevel;
	Mote* MoteById(int moteId);
	
	// Changes the value of the light sensor reading for the mote
	bool changeReading(int newReading, int moteId);
	
	// Adds a new mote to the collection if possible
	bool addMote(int moteId);
	bool addMote(Mote* m);
	
	std::vector <Mote*> motes; 
	
	//To give access to changeReading and motes
	friend class MoteBridge;
};

ostream& operator<<(ostream& out, const MoteCollection& c);

#endif // _MoteCollection_H
